#include <iostream>
using namespace std;

class Point{
public:
    Point():x(0),y(0){
        count++;
        cout<<"Default Constructor called."<<endl;
    }
    Point(int x, int y):x(x),y(y){
        count++;
        cout<<"Constructor called."<<endl;
    }
    Point(const Point &p):x(p.x),y(p.y){
        count++;
        cout<<"Copy constructor called."<<endl;
    }
    ~Point(){cout<<"Destructor called."<<endl;count--;}
    int getX() const{return x;}
    int getY() const{return y;}
    void move(int newX, int newY){
        x=newX;
        y=newY;
    }
    void print(){cout<<"x="<<x<<"\ty="<<y<<endl;}
    static int count;
private:
    int x,y;
};

class arrayOfPoints{
public:
    arrayOfPoints(int size):size(size){
        points=new Point[size];
    }
    ~arrayOfPoints(){
        cout<<"Deleting..."<<endl;
        delete[] points;
    }

    Point & element(int index){
        return points[index];
    }
    arrayOfPoints(const arrayOfPoints &v);
private:
    int size;
    Point *points;
};
arrayOfPoints::arrayOfPoints(const arrayOfPoints &v){
	size=v.size;
	points=new Point [size];
	for(int i=0;i<size;i++){
		points[i]=v.points[i];
	}
}
int Point::count=0;
int main() {
    arrayOfPoints pointsArray1(2);
    pointsArray1.element(0).move(5,10);
    pointsArray1.element(1).move(15,20);

    arrayOfPoints pointsArray2=pointsArray1;
    cout<<"Copy of pointsArray1:"<<endl;
    cout<<"p[0] of pointsArray2:";
    pointsArray2.element(0).print();
    cout<<"p[1] of pointsArray2:";
    pointsArray2.element(1).print();

    pointsArray1.element(0).move(25,30);
    pointsArray1.element(1).move(35,40);
    cout<<"After moving:"<<endl;
    cout<<"p[0] of pointsArray2:";
    pointsArray2.element(0).print();
    cout<<"p[1] of pointsArray2:";
    pointsArray2.element(1).print();
    return 0;
}

